<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.5.1.min.js"></script>
</head>
<body>
<h3>Hi,我是你的旅行指导派蒙</h3>
<h3>你可以选择以下的功能进行操作</h3>
<h3>Hi,我是你的旅行指导派蒙</h3>
<h3>你可以选择以下的功能进行操作</h3>
<h3>Hi,我是你的旅行指导派蒙</h3>
<h3>你可以选择以下的功能进行操作</h3>
<button onclick="f2()"></button>

<div>
    <form method="post" th:action="@{/login}">
        <p><input type="text" placeholder="请输入账号" maxlength="11" name="username" id="username"/><span></span></p>
        <p><input type="password" placeholder="请输入密码,长度：6-16位" maxlength="16" name="password" id="password"
                  pattern="\d{6,16}"/><span></span></p>
        <input type="button" value="登录" id="dl" onclick="f3()"/>
    </form>
</div>

<p th:text="${msg}">111</p>


</body>
<script>
    $(function () {
        f2();
    });

    function f1() {  //一加载界面就调用
        $.ajax({
            url: "testTest?num=1", success: function (result) {
                console.log(result)
            }
        });
    }

    function f2() {  //一加载界面就调用
        $.ajax({
            type: "post",
            url: "startup",
            data: {},
            success: function (data) {
                console.log(data)
            }
        })
    }

    function f3() {
        var $username = $("#username");
        var $password = $("#password");

        $.ajax({
            type: "post",
            url: "login",
            data: {
                username: $username.val(),
                password: $password.val()
            },
            success: function (data) {
                console.log(data)
                var msg = "${msg}";
                console.log(msg)
                window.location.href = "main/testpage"
            }
        })
    }
</script>
</html>